import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';

import 'option.dart';
import 'spec_name.dart';

part 'specification_list_item.g.dart';

@JsonSerializable()
class SpecificationListItem extends Equatable {
  factory SpecificationListItem.fromJson(Map<String, dynamic> json) =>
      _$SpecificationListItemFromJson(json);

  Map<String, dynamic> toJson() => _$SpecificationListItemToJson(this);

  @override
  List<Object> get props =>
      [specId, specNames, specName, options, orderValue, allowEdit];

  final String specId;
  final List<SpecName> specNames;

  final String specName;

  final List<Option> options;

  final String orderValue;

  final bool allowEdit;

  SpecificationListItem({
    this.specId,
    this.specNames,
    this.specName,
    this.options,
    this.orderValue,
    this.allowEdit,
  });

  SpecificationListItem copyWith(
      {String specId,
      List<SpecName> specNames,
      String specName,
      List<Option> options,
      String orderValue,
      bool allowEdit}) {
    return SpecificationListItem(
      specId: specId ?? this.specId,
      specName: specName ?? this.specName,
      specNames: specNames ?? this.specNames,
      options: options ?? this.options,
      orderValue: orderValue ?? this.orderValue,
      allowEdit: allowEdit ?? this.allowEdit,
    );
  }

  @override
  String toString() {
    return 'SpecificationListItem{specId: $specId, specNames: $specNames, specName: $specName, options: $options, orderValue: $orderValue, allowEdit: $allowEdit}';
  }
}
